package com.wpx.Controller;

import com.wpx.Pojo.optionsTypeVo;
import com.wpx.Pojo.type;
import com.wpx.Pojo.Article;
import com.wpx.Pojo.PageVO;
import com.wpx.Service.ArticleService;
import com.wpx.Service.TypeService;
import com.wpx.result.Result;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@CrossOrigin
@RestController
@RequestMapping("/type")
public class  TypeController{
    @Autowired
    public TypeService typeService;

    @GetMapping("getTypeList")
    public Result  getTypeList(){
         List<type>lt=  typeService.getTypeList();
         List<optionsTypeVo>lop=new ArrayList<>();
         if(!lt.isEmpty()){
             for (type type : lt) {
                 optionsTypeVo typeVo = new optionsTypeVo();
                 typeVo.setLabel(type.getType());
                 typeVo.setValue(type.getId());
                 lop.add(typeVo);
             }
         }
         return Result.ok(lop);

    }




}